<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>课程详细</title>
    {% load static %}
    <link href="{% static './layui/css/layui.css' %}" rel="stylesheet">
    <script src="{% static './layui/layui.js' %}"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
</head>
<body>
<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
  <ul class="layui-tab-title">
    <li class="layui-this">星期一</li>
    <li>星期二</li>
    <li>星期三</li>
    <li>星期四</li>
    <li>星期五</li>
  </ul>
  <div class="layui-tab-content">
    <div class="layui-tab-item layui-show">
        <form class="layui-form" action="">
          <div class="layui-form-item">
            <label class="layui-form-label">第一节课</label>
            <div class="layui-input-block">
              <input type="text" name="first_class" required value="{% if res.星期一 is not None %} {{res.星期一.first_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">第二节课</label>
            <div class="layui-input-block">
              <input type="text" name="second_class" required  value="{% if res.星期一 is not None %} {{res.星期一.second_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">第三节课</label>
            <div class="layui-input-block">
              <input type="text" name="third_class" required value="{% if res.星期一 is not None %} {{res.星期一.third_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">第四节课</label>
            <div class="layui-input-block">
              <input type="text" name="fourth_class" required value="{% if res.星期一 is not None %} {{res.星期一.fourth_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">第五节课</label>
            <div class="layui-input-block">
              <input type="text" name="fifth_class" required value="{% if res.星期一 is not None %} {{res.星期一.fifth_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">第六节课</label>
            <div class="layui-input-block">
              <input type="text" name="sixth_class" required value="{% if res.星期一 is not None %} {{res.星期一.sixth_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <div class="layui-input-block">
              <input type="hidden" name="master_id" value="{{mater_id}}">
            </div>
          </div>
          <div class="layui-form-item">
            <div class="layui-input-block">
              <input type="hidden" name="name" value="星期一">
            </div>
          </div>
          <div class="layui-form-item">
            <div class="layui-input-block">
              <button class="layui-btn" lay-submit lay-filter="monday_submit">立即提交</button>
              <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
          </div>
        </form>
    </div>
    <div class="layui-tab-item">
        <form class="layui-form" action="">
          <div class="layui-form-item">
            <label class="layui-form-label">第一节课</label>
            <div class="layui-input-block">
              <input type="text" name="first_class" required value="{% if res.星期二 is not None %} {{res.星期二.first_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">第二节课</label>
            <div class="layui-input-block">
              <input type="text" name="second_class" required value="{% if res.星期二 is not None %} {{res.星期二.second_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">第三节课</label>
            <div class="layui-input-block">
              <input type="text" name="third_class" required value="{% if res.星期二 is not None %} {{res.星期二.third_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">第四节课</label>
            <div class="layui-input-block">
              <input type="text" name="fourth_class" required value="{% if res.星期二 is not None %} {{res.星期二.fourth_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">第五节课</label>
            <div class="layui-input-block">
              <input type="text" name="fifth_class" required value="{% if res.星期二 is not None %} {{res.星期二.fifth_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">第六节课</label>
            <div class="layui-input-block">
              <input type="text" name="sixth_class" required value="{% if res.星期二 is not None %} {{res.星期二.sixth_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <div class="layui-input-block">
              <input type="hidden" name="master_id" value="{{master_id}}">
            </div>
          </div>
          <div class="layui-form-item">
            <div class="layui-input-block">
              <input type="hidden" name="name" value="星期二">
            </div>
          </div>
          <div class="layui-form-item">
            <div class="layui-input-block">
              <button class="layui-btn" lay-submit lay-filter="monday_submit">立即提交</button>
              <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
          </div>
        </form>
    </div>
    <div class="layui-tab-item">
        <form class="layui-form" action="">
          <div class="layui-form-item">
            <label class="layui-form-label">第一节课</label>
            <div class="layui-input-block">
              <input type="text" name="first_class" required value="{% if res.星期三 is not None %} {{res.星期三.firth_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">第二节课</label>
            <div class="layui-input-block">
              <input type="text" name="second_class" required value="{% if res.星期三 is not None %} {{res.星期三.second_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">第三节课</label>
            <div class="layui-input-block">
              <input type="text" name="third_class" required value="{% if res.星期三 is not None %} {{res.星期三.third_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">第四节课</label>
            <div class="layui-input-block">
              <input type="text" name="fourth_class" required value="{% if res.星期三 is not None %} {{res.星期三.fourth_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">第五节课</label>
            <div class="layui-input-block">
              <input type="text" name="fifth_class" required value="{% if res.星期三 is not None %} {{res.星期三.fifth_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">第六节课</label>
            <div class="layui-input-block">
              <input type="text" name="sixth_class" required value="{% if res.星期三 is not None %} {{res.星期三.sixth_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <div class="layui-input-block">
              <input type="hidden" name="master_id" value="{{master_id}}">
            </div>
          </div>
          <div class="layui-form-item">
            <div class="layui-input-block">
              <input type="hidden" name="name" value="星期三">
            </div>
          </div>
          <div class="layui-form-item">
            <div class="layui-input-block">
              <button class="layui-btn" lay-submit lay-filter="monday_submit">立即提交</button>
              <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
          </div>
        </form>
    </div>
    <div class="layui-tab-item">
        <form class="layui-form" action="">
          <div class="layui-form-item">
            <label class="layui-form-label">第一节课</label>
            <div class="layui-input-block">
              <input type="text" name="first_class" required value="{% if res.星期四 is not None %} {{res.星期四.firth_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">第二节课</label>
            <div class="layui-input-block">
              <input type="text" name="second_class" required value="{% if res.星期四 is not None %} {{res.星期四.second_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">第三节课</label>
            <div class="layui-input-block">
              <input type="text" name="third_class" required value="{% if res.星期四 is not None %} {{res.星期四.third_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">第四节课</label>
            <div class="layui-input-block">
              <input type="text" name="fourth_class" required value="{% if res.星期四 is not None %} {{res.星期四.fourth_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">第五节课</label>
            <div class="layui-input-block">
              <input type="text" name="fifth_class" required value="{% if res.星期四 is not None %} {{res.星期四.fifth_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">第六节课</label>
            <div class="layui-input-block">
              <input type="text" name="sixth_class" required value="{% if res.星期四 is not None %} {{res.星期四.sixth_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <div class="layui-input-block">
              <input type="hidden" name="master_id" value="{{master_id}}">
            </div>
          </div>
          <div class="layui-form-item">
            <div class="layui-input-block">
              <input type="hidden" name="name" value="星期四">
            </div>
          </div>
          <div class="layui-form-item">
            <div class="layui-input-block">
              <button class="layui-btn" lay-submit lay-filter="monday_submit">立即提交</button>
              <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
          </div>
        </form>
    </div>
    <div class="layui-tab-item">
        <form class="layui-form" action="">
          <div class="layui-form-item">
            <label class="layui-form-label">第一节课</label>
            <div class="layui-input-block">
              <input type="text" name="first_class" required value="{% if res.星期五 is not None %} {{res.星期五.first_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">第二节课</label>
            <div class="layui-input-block">
              <input type="text" name="second_class" required value="{% if res.星期五 is not None %} {{res.星期五.second_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">第三节课</label>
            <div class="layui-input-block">
              <input type="text" name="third_class" required value="{% if res.星期五 is not None %} {{res.星期五.third_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">第四节课</label>
            <div class="layui-input-block">
              <input type="text" name="fourth_class" required value="{% if res.星期五 is not None %} {{res.星期五.fourth_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">第五节课</label>
            <div class="layui-input-block">
              <input type="text" name="fifth_class" required value="{% if res.星期五 is not None %} {{res.星期五.fifth_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">第六节课</label>
            <div class="layui-input-block">
              <input type="text" name="sixth_class" required value="{% if res.星期五 is not None %} {{res.星期五.sixth_class}} {% endif %}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <div class="layui-input-block">
              <input type="hidden" name="master_id" value="{{master_id}}">
            </div>
          </div>
          <div class="layui-form-item">
            <div class="layui-input-block">
              <input type="hidden" name="name" value="星期五">
            </div>
          </div>
          <div class="layui-form-item">
            <div class="layui-input-block">
              <button class="layui-btn" lay-submit lay-filter="monday_submit">立即提交</button>
              <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
          </div>
        </form>
    </div>
  </div>
</div>
</body>
<script>
        //Demo
        layui.use('form', function(){
          var form = layui.form;
          //监听提交
          form.on('submit(monday_submit)', function(data){
            $.ajax({
                method: "POST",
                url: "{%url 'xyss_admin:majorSlaveApi' %}",
                data: {
                  name: data.field.name,
                  first_class: data.field.first_class,
                  second_class: data.field.second_class,
                  third_class: data.field.third_class,
                  fourth_class: data.field.fourth_class,
                  fifth_class: data.field.fifth_class,
                  sixth_class: data.field.sixth_class,
                  master_id: data.field.master_id,
                },
                success: function (res) {
                    if(res['code'] == 0){
                        layer.msg(res['msg'],{time:2000},
                            function(){
                                parent.layer.closeAll()
                                parent.location.reload();
                            }
                        );
                    }else{
                        layer.msg(res['msg']);
                    }
                },
                error: function(res) {
                    console.log("失败了: " + res['msg']);
                }
              });
            return false;
          });
        });
        </script>
</html>